﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace Broker.View.Converter
{
    public class StateConverter : IValueConverter
    {
        #region IValueConverter 成员

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string result = string.Empty;

            IList<string> states = (IList<string>)value;

            if (states != null)
            {
                foreach (string s in states)
                {
                    result += string.IsNullOrEmpty(result) ? s : ";" + s;
                }
            }
            return result;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string s = value as string;

            IList<string> ss = s.Split(';').ToList<string>();

            return ss;
        }

        #endregion
    }
}
